import Mock from 'mockjs'
import * as login from './admin/login'
import * as user from './admin/user'

/**
 * 创建mock模拟数据
 * @param {*} mod 业务模块
 * @param {*} isOpen 是否开启?
 */
function createMock (mod, isOpen = true) {
  if (isOpen) {
    for (var key in mod) {
      ((res) => {
        if (res.isOpen !== false) {
          Mock.mock(new RegExp(res.url), res.type, res.data)
        }
      })(mod[key]() || {})
    }
  }
}

createMock(login, true);
createMock(user, true);
